/**
 * Project managment
 */
 
var Project = 
{
    /**
     * Initalizing
     */  
    init: function()
    {
        var action = System.getAction();
        if(action == 'list' && $('.project-table').length != 0 )
        {
            this.createList(0);
        }
    },
    
    /**
     * Create project list with actions buttons
     * @param int page - page number to display 
    */
    createList: function(page)
    {        
        System.ProgressWindow("Trwa ładowanie dany. Proszę poczekać");
        
        $.ajax({
            url: System.buildEvent('get_project_list'),
            type: "post",
            data:{
                "page": page
            },
            dataType: 'json',
            success: function(data)
            {
                System.CloseProgressWindow();
                if(data.result)
                {
                    // TODO: How to print data without HTML, store smarty reference in session ?   
                                     
                }
            },
            error: function(){
                System.CloseProgressWindow();
                System.WindowTooltip('error',"Wystąpił błąd w działaniu eventu.");
            }
        })
    }
};

$(document).ready(function()
{
   Project.init(); 
});